home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / demos / plasma_copperpmc / plasma2.s < prev   
Text File  |  1980-01-03  |  9KB  |  564 lines

  1.  
  2. ; Resourced from Old PureMetalCoders demo, enhanced by phagex '92
  3. ;
  4. ; Quick ABS-Address fix by 2-Cool... fucked up phagex, listen mate next 
  5. ; time you go resoucing try to use non-absolute addressing.. its fucking 
  6. ; LAME!! and crashes everyone elses computer but your gas powered A500...
  7.  
  8.     section    "base code",code_c
  9.  
  10. lines    = 160
  11.  
  12. start    movem.l    d0-d7/a0-a6,-(sp) 
  13.     bsr    killsys      
  14.     
  15.     lea    copperlist0,a0 
  16.     lea    hardware,a6      
  17.     move.l    a0,cop1lc(a6)      
  18.     move.w    #$83c0,dmacon(a6)
  19.  
  20.     lea    copperlist0,a0
  21.     lea    copperlist1,a1
  22.     move.l    #$1000200,(a0)+    
  23.     move.l    #$1000200,(a1)+    
  24.     move.l    #$4001fffe,d0    
  25.     move.w    #199,d6
  26. setcolloop1    move.l    d0,(a0)+
  27.     move.l    d0,(a1)+
  28.     move.w    #44,d7
  29. setcolloop2    move.l    #$01800000,(a0)+
  30.     move.l    #$01800000,(a1)+
  31.     dbf    d7,setcolloop2
  32.     add.l    #$1000000,d0
  33.     dbf    d6,setcolloop1    
  34.     move.l    #$fffffffe,(a0)+
  35.     move.l    #$fffffffe,(a1)+
  36.  
  37.     bsr    dorgbsine
  38.  
  39. loop    bsr    vbl
  40.     bsr    doublebuffer
  41.     bsr    dowobble
  42.     bsr    doplasma
  43.     btst    #6,$bfe001    
  44.     bne    loop      
  45.         
  46.     bsr    returnsys      
  47.     movem.l    (sp)+,d0-d7/a0-a6 
  48.     moveq    #0,d0      
  49.     rts
  50.  
  51. doublebuffer    lea    copperpt(pc),a0
  52.     move.l    0(a0),d0
  53.     move.l    4(a0),d1
  54.     move.l    d0,4(a0)
  55.     move.l    d1,0(a0)
  56.     move.l    d0,$dff080
  57.     rts
  58.  
  59. dorgbsine    move.w    #0,d2
  60.     lea    plasmacolour,a0
  61. rgbsineloop    lea    redsine(pc),a2
  62.     bsr    sinewave
  63.     move.w    d4,0(a0)
  64.     lea    greensine(pc),a2
  65.     bsr    sinewave
  66.     asl.w    #4,d4
  67.     move.w    d4,2(a0)
  68.     lea    bluesine(pc),a2
  69.     bsr    sinewave
  70.     asl.w    #8,d4
  71.     move.w    d4,4(a0)    
  72.     move.w    #0,6(a0)
  73.     addq    #8,a0
  74.     add.w    #1,d2
  75.     cmp.w    #610,d2
  76.     bne    rgbsineloop
  77.     rts
  78.  
  79. sinewave    movem.l    d0-d3/a0-a1,-(sp)
  80.     lea    sinedata(pc),a0
  81.     move.l    00(a2),d0
  82.     move.l    04(a2),d1
  83.     move.l    08(a2),d2
  84.     move.l    12(a2),d3
  85.     and.l    #$7fe,d0
  86.     and.l    #$7fe,d1
  87.     and.l    #$1fe,d2
  88.     and.l    #$1fe,d3
  89.     add.l    d2,d0
  90.     add.l    d3,d1
  91.     move.l    d0,0(a2)
  92.     move.l    d1,4(a2)
  93.     move.w    (a0,d0),d4
  94.     add.w    (a0,d1),d4
  95.     add.l    #512,d4
  96.     asr.w    #6,d4
  97.     and.w    #$f,d4
  98.     movem.l    (sp)+,d0-d3/a0-a1
  99.     rts
  100.  
  101. redsine    dc.l    04
  102.     dc.l    34
  103.     dc.l    14
  104.     dc.l    22
  105.  
  106. greensine    dc.l    42
  107.     dc.l    22
  108.     dc.l    8
  109.     dc.l    2
  110.  
  111. bluesine    dc.l    34
  112.     dc.l    28
  113.     dc.l    10
  114.     dc.l    14
  115.  
  116. dowobble    move.l    wobblesine0(pc),d0
  117.     move.l    wobblesine1(pc),d1
  118.     move.l    wobblesine2(pc),d2
  119.     move.l    wobblesine3(pc),d3
  120.     lea    plasmasine(pc),a4
  121.     lea    plasmasine+$100(pc),a5
  122.     move.l    a4,d4
  123.     move.l    a5,d5
  124.     move.l    #$100,d7
  125.     lea    wobblesine0pt(pc),a1
  126.     lea    wobblesine1pt(pc),a2
  127.     add.l    d0,(a1)
  128.     cmp.l    (a1),d5
  129.     bhi    findsine1
  130.     sub.l    d7,(a1)
  131.     bra    foundsine1
  132.  
  133. findsine1    cmp.l    (a1),d4
  134.     bls    foundsine1
  135.     add.l    d7,(a1)
  136. foundsine1    add.l    d1,(a2)
  137.     cmp.l    (a2),d5
  138.     bhi    findsine2
  139.     sub.l    d7,(a2)
  140.     bra    foundsine2
  141.  
  142. findsine2    cmp.l    (a2),d4
  143.     bls    foundsine2
  144.     add.l    d7,(a2)
  145. foundsine2    move.l    copperpt(pc),a0
  146.     add.l    #$5,a0
  147.     move.l    wobblesine0pt(pc),a1
  148.     move.l    wobblesine1pt(pc),a2
  149.     lea    $100,a3
  150.     move.w    #lines-1,d0
  151.     move.l    #$b8,d1
  152.     moveq.l    #1,d4
  153.     moveq.l    #0,d6
  154.     moveq.l    #$1b,d7
  155. dowobbleloop    add.l    d2,a1
  156.     cmp.l    d5,a1
  157.     bcs    endwobtab
  158.     sub.l    a3,a1
  159. endwobtab    add.l    d3,a2
  160.     cmp.l    d5,a2
  161.     bcs    setwobble
  162.     sub.l    a3,a2
  163. setwobble    move.b    (a1),d6
  164.     add.b    (a2),d6
  165.     lsr.b    d4,d6
  166.     lsl.b    d4,d6
  167.     add.b    d7,d6
  168.     move.b    d6,(a0)
  169.     add.l    d1,a0
  170.     dbra    d0,dowobbleloop
  171.     rts    
  172.  
  173. doplasma    move.l    plasmasine0(pc),d0
  174.     move.l    plasmasine1(pc),d4
  175.     move.l    plasmasine2(pc),d1
  176.     move.l    plasmasine3(pc),d5
  177.     move.l    plasmasine4(pc),d2
  178.     move.l    plasmasine5(pc),d6
  179.     move.l    plasmasine6(pc),d3
  180.     move.l    plasmasine7(pc),d7
  181.     lea    plasmasine0pt(pc),a0
  182.     lea    plasmasine1pt(pc),a1
  183.     lea    plasmasine2pt(pc),a2
  184.     lea    plasmasine3pt(pc),a3
  185.     lea    plasmacolour,a4
  186.     add.l    d0,d0
  187.     add.l    d1,d1
  188.     add.l    d2,d2
  189.     add.l    d3,d3
  190.     add.l    d4,d4
  191.     add.l    d5,d5
  192.     add.l    d6,d6
  193.     add.l    d7,d7
  194.     add.l    d0,(a0)
  195.     cmp.l    #plasmasine+$2040,(a0)
  196.     bcs    getredsine
  197.     sub.l    #$1f40,(a0)
  198.     bra.s    gotredsine
  199.  
  200. getredsine    cmp.l    #plasmasine+$100,(a0)
  201.     bcc    gotredsine
  202.     add.l    #$1f40,(a0)
  203. gotredsine    add.l    d1,(a1)
  204.     cmp.l    #plasmasine+$2040,(a1)
  205.     bcs    getgreensine
  206.     sub.l    #$1f40,(a1)
  207.     bra.s    gotgreensine
  208.  
  209. getgreensine    cmp.l    #plasmasine+$100,(a1)
  210.     bcc    gotgreensine
  211.     add.l    #$1f40,(a1)
  212. gotgreensine    add.l    d2,(a2)
  213.     cmp.l    #plasmasine+$2040,(a2)
  214.     bcs    getbluesine
  215.     sub.l    #$1f40,(a2)
  216.     bra.s    gotbluesine
  217.  
  218. getbluesine    cmp.l    #plasmasine+$100,(a2)
  219.     bcc    gotbluesine
  220.     add.l    #$1f40,(a2)
  221. gotbluesine    add.l    d3,(a3)
  222.     cmp.l    #plasmasine+$2040,(a3)
  223.     bcs    sinesfound
  224.     sub.l    #$1f40,(a3)
  225.     bra.s    setnewsine
  226.  
  227. sinesfound    cmp.l    #plasmasine+$100,(a3)
  228.     bcc    setnewsine
  229.     add.l    #$1f40,(a3)
  230. setnewsine    move.l    (a0),a0
  231.     move.l    (a1),a1
  232.     move.l    (a2),a2
  233.     move.l    (a3),a3
  234.     move.l    copperpt(pc),d2
  235.     add.l    #$a,d2
  236.     move.l    a4,d3
  237.     bsr    waitblitter
  238.     move.w    #6,$dff064
  239.     move.w    #6,$dff062
  240.     move.w    #6,$dff060
  241.     move.w    #$b6,$dff066
  242.     move.l    #-1,$dff044
  243.     move.w    #$ffe,$dff040
  244.     move.w    #0,$dff042
  245.     move.l    a6,-(sp)
  246.     lea    xcount(pc),a6
  247.     move.w    #0,(a6)
  248.     move.l    (sp)+,a6
  249. checksine1    add.l    d4,a0
  250.     cmp.l    #plasmasine+$2040,a0
  251.     bcs    checksine2
  252.     sub.l    #$1f40,a0
  253. checksine2    add.l    d5,a1
  254.     cmp.l    #plasmasine+$2040,a1
  255.     bcs    checksine3
  256.     sub.l    #$1f40,a1
  257. checksine3    add.l    d6,a2
  258.     cmp.l    #plasmasine+$2040,a2
  259.     bcs    checksine4
  260.     sub.l    #$1f40,a2
  261. checksine4    add.l    d7,a3
  262.     cmp.l    #plasmasine+$2040,a3
  263.     bcs    setrgbblit
  264.     sub.l    #$1f40,a3
  265. setrgbblit    moveq.l    #0,d0
  266.     move.w    (a0),d0
  267.     move.w    (a1),d1
  268.     add.w    d1,d0
  269.     lsr.w    #1,d0
  270.     lsl.w    #3,d0
  271.     move.l    d3,a4
  272.     add.l    #2,d3
  273.     add.l    d0,a4
  274.     move.w    (a1),d0
  275.     move.w    (a2),d1
  276.     add.w    d1,d0
  277.     lsr.w    #1,d0
  278.     lsl.w    #3,d0
  279.     move.l    d3,a5
  280.     add.l    #2,d3
  281.     add.l    d0,a5
  282.     move.w    (a2),d0
  283.     move.w    (a3),d1
  284.     add.w    d1,d0
  285.     lsr.w    #1,d0
  286.     lsl.w    #3,d0
  287.     move.l    d3,a6
  288.     add.l    #2,d3
  289.     add.l    d0,a6
  290.     bsr    waitblitter
  291.     move.l    a4,$dff050
  292.     move.l    a5,$dff04c
  293.     move.l    a6,$dff048
  294.     move.l    d2,$dff054
  295.     move.w    #(lines*64)+1,$dff058
  296.     sub.l    #6,d3
  297.     add.l    #4,d2
  298.     move.l    a6,-(sp)
  299.     lea    xcount(pc),a6
  300.     add.w    #1,(a6)
  301.     move.w    (a6),d0
  302.     move.l    (sp)+,a6
  303.     cmp.w    #$2d,d0
  304.     bne    checksine1
  305.     bsr    waitblitter
  306.     rts    
  307.     
  308. waitblitter    btst    #14,$dff002
  309.     bne    waitblitter
  310.     rts
  311.  
  312. vbl    move.l    $dff004,d0
  313.     and.l    #$1ff00,d0
  314.     cmp.l    #$13000,d0
  315.     bne    vbl
  316.     rts
  317.  
  318. killsys    bsr.s    syswait    
  319.  
  320.     move.l    $4,a6    
  321.     lea    gfxname(pc),a1    
  322.     moveq    #0,d0    
  323.     jsr    -552(a6)    
  324.         
  325.     lea    oldcop1(pc),a5
  326.     move.l    $26(a0),$0(a5)    
  327.     move.l    $32(a0),$4(a5)    
  328.     
  329.     lea    hardware,a6
  330.     move.w    intenar(a6),d0    
  331.     move.w    dmaconr(a6),d1  
  332.     or.w    #$8000,d0    
  333.     and.w    #$03ff,d1    
  334.     or.w    #$8000,d1    
  335.     move.w    d0,$8(a5)    
  336.     move.w    d1,$a(a5)    
  337.     
  338.     move.w    #$7fff,intena(a6) 
  339.     move.w    #$7fff,dmacon(a6) 
  340.     rts
  341.  
  342. syswait    move.w    #15,d7    
  343. syswaitloop    move.l    #$05000,d1    
  344.     bsr.s    waitvbl    
  345.     bsr.s    dowaitvbl    
  346.     dbf    d7,syswaitloop    
  347.     rts
  348.  
  349. dowaitvbl    move.l    #$03000,d1    
  350. waitvbl    movem.l    d0-d1/a6,-(sp)    
  351.     lea    hardware,a6    
  352. waitvblloop    move.l    vposr(a6),d0    
  353.     and.l    #$1ff00,d0    
  354.     cmp.l    d1,d0    
  355.     bne.s    waitvblloop    
  356.     movem.l    (sp)+,d0-d1/a6    
  357.     rts        
  358.  
  359. returnsys    lea    hardware,a6    
  360.     move.w    oldintena(pc),intena(a6)
  361.     move.w    olddmacon(pc),dmacon(a6)
  362.     move.l    oldcop1(pc),cop1lc(a6)
  363.     move.l    oldcop2(pc),cop2lc(a6)
  364.     rts
  365.  
  366. gfxname    dc.b    "graphics.library",0
  367.     even
  368. oldcop1    dc.l    0    
  369. oldcop2    dc.l    0    
  370. oldintena    dc.w    0    
  371. olddmacon    dc.w    0    
  372. screen        dc.l    plasmacolour
  373. xcount        dc.w    0
  374.  
  375. wobblesine0    dc.l    13
  376. wobblesine1    dc.l    8
  377. wobblesine2    dc.l    11
  378. wobblesine3    dc.l    3
  379.  
  380. wobblesine0pt    dc.l    plasmasine
  381. wobblesine1pt    dc.l    plasmasine
  382.  
  383. copperpt    dc.l    copperlist0
  384. copperpt1    dc.l    copperlist1
  385.  
  386. plasmasine0    dc.l    $64
  387. plasmasine1    dc.l    $36
  388. plasmasine2    dc.l    $10
  389. plasmasine3    dc.l    $23
  390. plasmasine4    dc.l    $52
  391. plasmasine5    dc.l    $8
  392. plasmasine6    dc.l    $22
  393. plasmasine7    dc.l    $33
  394.  
  395. plasmasine0pt    dc.l    plasmasine+$100
  396. plasmasine1pt    dc.l    plasmasine+$100
  397. plasmasine2pt    dc.l    plasmasine+$100
  398. plasmasine3pt    dc.l    plasmasine+$100
  399.  
  400. tabvar1    dc.l    0
  401. tabvar2    dc.l    0
  402. tabvar3    dc.l    0
  403. tabvar4    dc.l    0
  404. tabvar5    dc.l    0
  405. tabvar6    dc.l    0
  406. tabvar7    dc.l    0
  407. tabvar8    dc.l    0
  408.  
  409. cmv    macro
  410.     dc.w    \2,\1
  411.     endm
  412.     
  413. cwt    macro
  414.     dc.w    (\1*$100)+$01,$fffe
  415.     endm    
  416.  
  417. pal    macro
  418.     dc.w    $ffe1,$fffe
  419.     endm    
  420.  
  421. endcop    macro
  422.     dc.w    $ffff,$fffe
  423.     endm    
  424.  
  425. plasmasine        incbin    dl:pmc.sine1
  426. sinedata        incbin    dl:sine1024bs.dat
  427.             incbin    dl:sine1024bs.dat
  428.  
  429.  
  430.  
  431.         section    mem,bss_c
  432.         
  433.  
  434. plasmacolour        ds.b    $2000        ;= $c0000
  435. copperlist0        ds.b    $16000        ;= $c2000
  436. copperlist1        ds.b    $16000        ;= $d0000
  437.  
  438. ****custom chip registers****
  439.  
  440. hardware    = $dff000
  441.  
  442. ;control registers
  443.  
  444. dmaconr    = $002
  445. vposr    = $004
  446. vhposr    = $006
  447. joy0dat    = $00a
  448. joy1dat    = $00c
  449. clxdat    = $00e
  450. intenar    = $01c
  451. intereqr    = $01e
  452. copcon    = $02e
  453.  
  454. ;blitter registers
  455.  
  456. bltcon0    = $040
  457. bltcon1    = $042
  458. bltafwm    = $044
  459. bltalwm    = $046
  460. bltcpth    = $048
  461. bltcptl    = $04a
  462. bltbpth    = $04c
  463. bltbptl    = $04e
  464. bltapth    = $050
  465. bltaptl    = $052
  466. bltdpth    = $054
  467. bltdptl    = $056
  468. bltsize    = $058
  469. bltcmod    = $060
  470. bltbmod    = $062
  471. bltamod    = $064
  472. bltdmod    = $066
  473. bltcdat    = $070
  474. bltbdat    = $072
  475. bltadat    = $074
  476.  
  477. ;copper registers
  478.  
  479. cop1lc    = $080
  480. cop1lch    = $080
  481. cop1lcl    = $082
  482. cop2lc    = $084
  483. cop2lch    = $084
  484. cop2lcl    = $086
  485. copjmp1    = $088
  486. copjmp2    = $08a
  487. diwstrt    = $08e
  488. diwstop    = $090
  489. ddfstrt    = $092
  490. ddfstop    = $094
  491. dmacon    = $096
  492. clxcon    = $098
  493. intena    = $09a
  494. intreq    = $09c
  495.  
  496. ;bitplane registers 
  497.  
  498. bplcon0    = $100
  499. bplcon1    = $102
  500. bplcon2    = $104
  501. bplmod1    = $108
  502. bplmod2    = $10a
  503.  
  504. bplpt0h    = $0e0
  505. bplpt0l    = $0e2
  506. bplpt1h    = $0e4
  507. bplpt1l    = $0e6
  508. bplpt2h    = $0e8
  509. bplpt2l    = $0ea
  510. bplpt3h    = $0ec
  511. bplpt3l    = $0ee
  512. bplpt4h    = $0f0
  513. bplpt4l    = $0f2
  514. bplpt5h    = $0f4
  515. bplpt5l    = $0f6
  516.  
  517. ;colour registers
  518.  
  519. color00    = $180
  520. color01    = $182
  521. color02    = $184
  522. color03    = $186
  523. color04    = $188
  524. color05    = $18a
  525. color06    = $18c
  526. color07    = $18e
  527. color08    = $190
  528. color09    = $192
  529. color10    = $194
  530. color11    = $196
  531. color12    = $198
  532. color13     = $19a
  533. color14     = $19c
  534. color15     = $19e
  535. color16     = $1a0
  536. color17     = $1a2
  537. color18     = $1a4
  538. color19     = $1a6
  539. color20     = $1a8
  540. color21     = $1aa
  541. color22     = $1ac
  542. color23     = $1ae
  543. color24     = $1b0
  544. color25     = $1b2
  545. color26     = $1b4
  546. color27     = $1b6
  547. color28     = $1b8
  548. color29     = $1ba
  549. color30     = $1bc
  550. color31     = $1be
  551.  
  552. ecsnop    = $1fe
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.